<!--
+----------------------------------------------------------------------
| 友得云客  - 开启房产营销新纪元
+----------------------------------------------------------------------
| Copyright (c) 2019~2023 优得（西安）信息科技有限公司版权所有
+----------------------------------------------------------------------
| Licensed 友得云客不是自由软件 未经允许不可移除相关版权
+----------------------------------------------------------------------
| Author: www.youdeyunke.com
+----------------------------------------------------------------------
-->
<template>
    <div >
    <ai-spider @success="done" @error="done" @close="done"   spiderId="POST_LIST"  ref="aiSpider" ></ai-spider>
    <el-dialog width="320px" :visible.sync="showDialog" v-loading="loading" :show-close="true" title="AI导入厂房"  modal-append-to-body>
        <el-form>
            <el-form-item label="请选择城市">
                <city-selector v-model="cityId"></city-selector>
            </el-form-item>
        </el-form>
        <div class="footer">
            <el-button style="margin-right:10px" @click="() => { showDialog = false }" size="small" icon="el-icon-close">取消</el-button>
            <el-button type="primary" :disabled="!cityId"  size="small" icon="el-icon-right" @click="startHandle">确定</el-button>
        </div>

        <!-- <AiProxyConfig :show.sync="showProxySet" @cancle="showProxySet = false" @success="proxysetsuccess"></AiProxyConfig> -->

    </el-dialog>
    </div>
</template>

<script>
import AiSpider from "@/components/AiSpider/index.vue";
import CitySelector from "@/components/CitySelector.vue";
export default {
    name: 'result',
    data() {
        return {
            cityId:null,
            loading: false,
            showDialog: false,
        }
    },
    components: {
        CitySelector,
        AiSpider,
    },
    props: {
    },
    watch: {
    },
    methods: {
        done:function(){
            this.$emit("done");
        },
        startHandle: function(){
            if(!this.cityId){
                this.$message.error("请先选择要爬取的城市");
                return false;
            }
            var data = {
                city_id: this.cityId,
            }
            this.$refs.aiSpider.start(data, (resp) => {
                console.log('spider resp:', resp);
                this.showDialog = false;
            });

        },

        open: function(){
            this.showDialog = true;
        },


        submitHandle: function (e) {
        },

    },
    mounted: function () {
    }

}
</script>

<style scoped>
.footer {
    display: flex;
    justify-content: flex-end;
}
</style>
